<?php

/**
 * @author NgAnh
 * @copyright 2013
 */
class Informodel extends CI_Model {
    var $infor_id;
    var $student_id;
    var $type_id;
    var $class_id;
    var $first_name;
    var $last_name;
    var $contact_address;
    var $phone;
    var $hand_phone;
    var $email;
    var $survey_date;
    var $survey_id;
    var $is_deleted;
    var $created_by_user_id;
    var $created_on_date;
    var $last_modified_by_user_id;
    var $last_modified_on_date;
    var $interviewer_id;
    var $interview_on_date;
    
    function __construct()
    {
        // Call the Model constructor
        $this->load->database();
    }
 	//Get infors list by survey id; Call from survey/check-delete
    function get_infors_list($sid){
        $query = $this->db->get_where('sur_infor', array('survey_id' => $sid, 'is_deleted' => 'false'));
        return $query;
    }
    //get all infor
    function get_all(){
        $query = $this->db->get_where('sur_infor', array('is_deleted'=>false));
        return $query->result_array();
    }
    
    function get_infors_list_class($sid,$facul){
        $query =$this->db->query("SELECT infor.* From sur_infor as infor, sur_class as class, sur_trade as trade, sur_faculty as faculty 
                        WHERE infor.class_id = class.class_id 
                        and class.trade_id = trade.trade_id and trade.faculty_id = faculty.faculty_id and infor.survey_id = '".$sid."' 
                        and faculty.faculty_id = '".$facul."' and infor.is_deleted = 'False'");
       //$this->db->where('survey_id',$sid);
       //$this->db->where('class_id',$clas);
       //$this->db->where('is_deleted',False);  
       //$query=$this->db->get('sur_infor');  
       return $query;
    }
    function check_exists($id){
        $query = $this->db->get_where('sur_infor', array('survey_id' => $id));
        //$ques_id = $query->result_array('$question_id');
        $arrlen = $query->num_rows();
        if($arrlen == 0){
            return "false";// no answer
        }
        else{
            return "true";// have answer
        }
    }
}


?>